package com.dxy.yesas2020goals.study.partone.disignpattern.factorypattern.simplefactory;

/**
 * @author victorydeng
 * @Classname KouZhaoFactory
 * @Description 生产口罩产品的简单工厂
 * @Date 2020/2/26 23:38
 * @Created by victorydeng
 */
public class KouZhaoFactory {

  // -------------------使用名字匹配 start
//  private KouZhao kouZhao;
//    KouZhao create(String name ){
//      if("KN95".equalsIgnoreCase(name)){
//        kouZhao = new KN95KouZhao();
//      } else if("KN94".equalsIgnoreCase(name)){
//        kouZhao = new KN94KouZhao();
//      } else if("KF94".equalsIgnoreCase(name)){
//        kouZhao = new KF94KouZhao();
//      }
//     return kouZhao;
//    }
  // -------------------使用名字匹配 end
  // -------------------使用反射匹配 start
  KouZhao create(Class<? extends KouZhao> clazz) {
    try {
      if (clazz != null) {
        return clazz.newInstance();
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    return null;
  }
  // -------------------使用反射匹配 end


}
